package com.woniuxy.secondhand.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.life.core.api.CommonResult;
import com.woniuxy.secondhand.entity.SecGoods;
import com.woniuxy.secondhand.entity.SecGoodsorder;
import com.woniuxy.secondhand.entity.SecOrderitem;
import com.woniuxy.secondhand.mapper.SecGoodsMapper;
import com.woniuxy.secondhand.mapper.SecGoodsorderMapper;
import com.woniuxy.secondhand.mapper.SecOrderitemMapper;
import com.woniuxy.secondhand.service.SecGoodsorderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * <p>
 * 二手订单 服务实现类
 * </p>
 *
 * @author chaohuijiang
 * @since 2020-09-24
 */
@Service
public class SecGoodsorderServiceImpl extends ServiceImpl<SecGoodsorderMapper, SecGoodsorder> implements SecGoodsorderService {
   @Resource
    SecGoodsMapper secGoodsMapper;
   @Resource
    SecGoodsorderMapper secGoodsorderMapper;
   @Resource
    SecOrderitemMapper secOrderitemMapper;
    @Override
    public CommonResult<SecGoodsorder> insert(Integer secGoodsId,SecGoodsorder secGoodsorder) {
        SecOrderitem secOrderitem=new SecOrderitem();
        SecGoods secGoods=secGoodsMapper.selectById(secGoodsId);
        //订单编号
        String ordernumber="sc"+new Date();
        secGoodsorder.setOrdernumber(ordernumber);
        secGoodsorder.setTotalprice(secGoods.getPrice());
        //订单项
        secOrderitem.setOrdernumber(ordernumber);
        secOrderitem.setGoodsid(secGoodsId);
        return CommonResult.success();
    }
}
